home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts44-07
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c
- Subject: Re: Newbie C programmer needs help Please!!!
- Date: Fri, 02 Feb 96 18:29:49 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4etksv$7s1@sam.inforamp.net>
- References: <4eca9l$vfn@grouper.Exis.Net>
- NNTP-Posting-Host: ts44-07.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4eca9l$vfn@grouper.Exis.Net>, herborn@exis.net wrote:
- >I'm taking a C course and have an assignment to write a C program to
- >compute all the combo's of coins that can make up a dollar. I've been
- >working on the solution to this for a couple of days and can't get it.
- >
- >
- >Anyone willing to jump start my brain for me. I'm not looking for
- >someone else to do my work, just some pointers on how to tackle the
- >task. Code is supposed to be simple, the farthest we've gone in
- >class is loops & simple functions.
- >
- >If you're willing to help, please respond via e-mail.
- >
- >TIA
- >
- >Steve
- >
-
- I'm from Canada so we might make a culture differences.
- Four quarters make a dollar, ten dimes, twenty nickles, 100 pennies.
- Thus we have,
-
- int q,d,n,p;
- for (q=0;q<5;q++)
- for (d=0;d<11;d++)
- for (n=0;n<21;n++)
- for (p=0;p<101;p++)
- if (q*25+d*10+n*5+p==100)
- {
- /* print result */
- cprintf("%d quarters, %d dimes, %d nickles, %d pennies", q, d, n, p);
- }
-
- Agrivar
-